﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="MyClients.aspx.cs" Inherits="MyClients" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
    <asp:Panel ID="AuthenticatedHeaderPanel" runat="server">
        <ul id="user">
            <li>
                <asp:LoginStatus ID="LoginStatus1" runat="server" LogoutAction="Redirect" LogoutPageUrl="~/Login.aspx" />
            </li>
        </ul>
        <div id="header-inner">
            <div class="textt">
                <h4>
                    <asp:Label runat="server" ID="WelcomeBackMessage"></asp:Label>
                    <asp:Label ID="lblMessage" runat="server" EnableViewState="false" />
                </h4>
            </div>
        </div>
    </asp:Panel>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Menu" runat="Server">
    <div id="left">
        <div id="navigation">
            <asp:Panel runat="server" ID="AuthenticatedMenuPanel" Width="200px">
                <div id="menu-header">
                    <div class="menutext">
                        <asp:Label ID="Label2" runat="server" Text="Menu" />
                    </div>
                </div>
                <asp:Menu ID="Menu1" runat="server" StaticDisplayLevels="3" BackColor="White" DynamicHoverStyle-BorderStyle="NotSet"
                    Width="200px">
                    <Items>
                        <asp:MenuItem Text="Home" Value="Home" NavigateUrl="Default.aspx">
                            <%--<asp:MenuItem Text="New Document" Value="New Document" NavigateUrl="AddDocument.aspx">
                            </asp:MenuItem>--%>
                        </asp:MenuItem>
                        <asp:MenuItem Text="Users" Value="My_Users" NavigateUrl="MyUsers.aspx">
                            <%--<asp:MenuItem Text="New User" Value="New_User" NavigateUrl="AddUser.aspx"></asp:MenuItem>--%>
                        </asp:MenuItem>
                        <asp:MenuItem Text="Companies" Value="Companies" NavigateUrl="MyCompanies.aspx">
                            <%--<asp:MenuItem Text="New Company" Value="New_Company" NavigateUrl="AddCompany.aspx">
                            </asp:MenuItem>--%>
                        </asp:MenuItem>
                        <asp:MenuItem Text="Clients" Value="Clients" NavigateUrl="MyClients.aspx">
                            <%--<asp:MenuItem Text="New Client" Value="New_Client" NavigateUrl="AddClient.aspx">
                            </asp:MenuItem>--%>
                        </asp:MenuItem>
                    </Items>
                </asp:Menu>
            </asp:Panel>
        </div>
    </div>
</asp:Content>
<asp:Content ID="Content3" runat="server" ContentPlaceHolderID="MainContent">
<asp:ScriptManager ID="ScriptManager1" runat="server"/>
    <div id="right">
        <asp:Panel runat="server" ID="AuthenticatedMessagePanel">
            <div class="box">
                <div class="title">
                    <h6>
                        <asp:Label ID="Label1" runat="server" Text="Your clients"></asp:Label>
                    </h6>
                </div>
                <div class="lists">
                <asp:UpdateProgress ID="UpdateProgress6" runat="server">
                   <ProgressTemplate>
                    <div id="progressBackgroundFilter"></div>
                        <div id="processMessage">
                            <asp:Image ID="Please_wait2" runat="server" ImageUrl="~/Images/Please_Wait.gif" />
                        </div>
                   </ProgressTemplate>
                </asp:UpdateProgress>

                <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="Update_Client_list">
                   <ProgressTemplate>
                    <div id="progressBackgroundFilter"></div>
                        <div id="processMessage">
                            <asp:Image ID="Please_wait" runat="server" ImageUrl="~/Images/Please_Wait.gif" />
                        </div>
                   </ProgressTemplate>
                </asp:UpdateProgress>
                <asp:UpdatePanel ID="Update_Client_list" runat="server" UpdateMode="Conditional">
                <ContentTemplate>
                    <asp:ListView ID="Client_list" runat="server" OnItemCommand="Client_list_ItemCommand" OnPagePropertiesChanging="Client_list_PagePropertiesChanging" OnItemEditing="Client_list_Editing" OnItemDeleting="Client_list_ItemDeleting">
                        <LayoutTemplate>
                            <table id="gradient-style" class="tab">
                                <thead>
                                    <tr>
                                        <th></th>
                                        <th>Name</th>
                                        <th>Reg. nr.</th>
                                        <th>Vat</th>
                                        <th>Main Client</th>
                                        <th>Position</th>
                                        <th>Status</th>
                                        <th colspan="2">Options</th>
                                    </tr>
                                </thead>
                                <tr id="itemPlaceholder" runat="server"></tr>
                                <tfoot>
                                    <tr>
                                        <th style="text-align: right" colspan="9">
                                            <asp:DataPager ID="Client_list_Page" runat="server" PagedControlID="Client_list" PageSize="5">
                                                <Fields>
                                                    <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" />
                                                    <asp:NumericPagerField />
                                                    <asp:TemplatePagerField>
                                                        <PagerTemplate>
                                                            Page
                                                            <asp:Label runat="server" ID="labelCurrentPage" Text="  <%  #  Container.TotalRowCount > 0 ? (Container.StartRowIndex / Container.PageSize) + 1 : 0  %>  " />
                                                            /
                                                            <asp:Label runat="server" ID="labelTotalPages" Text="  <%  #   Math.Ceiling ((double)Container.TotalRowCount / Container.PageSize)  %>  " />
                                                        </PagerTemplate>
                                                    </asp:TemplatePagerField>
                                                    <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" />
                                                </Fields>
                                            </asp:DataPager>
                                        </th>
                                    </tr>
                                </tfoot>
                            </table>
                        </LayoutTemplate>
                        <ItemTemplate>
                            <tr>
                                <td>
                                    <asp:CheckBox ID="cb_delete_clients" runat="server" />
                                </td>
                                <td>
                                    <asp:Label ID="client_nameLabel" runat="server" Text='<%# Eval("_company_name") %>'/>
                                    <%--<asp:LinkButton ID="client_nameLabel" runat="server" Text='<%# Eval("_company_name") %>' CommandName="Client" />--%>
                                </td>
                                <td id="id_user_client" runat="server" Visible="false">
                                    <asp:Label ID="id_user_clientLabel" runat="server" Text='<%# Eval("_id_user_company") %>' Visible="false"/>
                                </td>
                                <td id="id_user" runat="server" Visible="false">
                                    <asp:Label ID="id_userLabel" runat="server" Text='<%# Eval("_id_user") %>' Visible="false"/>
                                </td>
                                <td id="id_client" runat="server" Visible="false">
                                    <asp:Label ID="id_clientLabel" runat="server" Text='<%# Eval("_id_company") %>' Visible="false"/>
                                </td>
                                <td>
                                    <asp:Label ID="client_reg_nrLabel" runat="server" Text='<%# Eval("_company_reg_nr") %>' />
                                </td>
                                <td>
                                    <asp:Label ID="client_vatCheckBox" runat="server" Text='<%# Eval("_company_vat") %>' />
                                </td>
                                <td>
                                    <asp:CheckBox ID="main_clientCheckBox" runat="server" Checked='<%# Eval("_main_company") %>' Enabled="false" />
                                </td>
                                <td>
                                    <asp:Label ID="positionLabel" runat="server" Text='<%# Eval("_position") %>' />
                                </td>
                                <td>
                                    <asp:Label ID="statusLabel" runat="server" Text='<%# Eval("_status") %>' />
                                </td>
                                <td>
                                    <asp:ImageButton ID="lnkEdit" runat="server" CommandName="Edit" ImageUrl="~/Images/file_edit.png" ToolTip="Edit" />
                                </td>
                                <td>
                                    <asp:ImageButton ID="lnkDelete" runat="server" CommandName="Delete" ImageUrl="~/Images/file_delete.png" ToolTip="Delete" />
                                </td>
                            </tr>
                        </ItemTemplate>
                    </asp:ListView>                    
                    <div class="message-notice" id="message_no_clients" runat="server">
                        <div class="image">
                            <img height="32" alt="Notice" src="Images/notice.png">
                        </div>
                        <div class="text">
                            <h4>You have no clients!</h4>
                        </div>
                    </div>
                <%--Company Popup--%>
                <asp:Panel ID="Add_client" runat="server" CssClass="popupBody" style="display:none;">
                    <div class="popupContainer" style="width: auto; min-width: 400px; max-height:600px;">
                       <div class="popupTitlebar">
                            <div class="titlebarLeft">
                                <asp:Literal ID="lit_add_client" runat="server"/>
                            </div>
                            <div class="titlebarRight" onclick="OnCancel();"></div>
                       </div>
                       <div class="popupBody" style="height:600px;">
                          <asp:UpdatePanel ID="Update_Client_popup" runat="server">
                            <ContentTemplate>
                            <asp:Label ID="lbl_client_id" runat="server" Text=""></asp:Label>
                            <asp:Label ID="lbl_user_client_id" runat="server" Text=""></asp:Label>
                            <asp:Label ID="lbl_user_id" runat="server" Text=""></asp:Label>
                            <asp:Label ID="lbl_edit_client" runat="server" Text=""></asp:Label>
                            <ajaxToolkit:TabContainer ID="TabCont_Client" runat="server" CssClass="tab" ActiveTabIndex="0">
                                <ajaxToolkit:TabPanel ID="tab_add_client" HeaderText="Add client" runat="server">
                                    <ContentTemplate>
                                         <table style="color: #292929; font-family: Arial,Helvetica,sans-serif; font-size: 0.9em; line-height: 1.4em; padding: 5px 7px; width:100%; text-align:left;">
                                            <tbody>
                                                 <tr>
                                                    <th style="border-right: none; border-bottom: 1px solid #CDCDCD; text-align: left; padding: 3px 1px 4px 0; height:50px;">User: <asp:Label ID="lbl_user" runat="server" Text=""></asp:Label></th>                                                                                                        
                                                 </tr>                                                                                                  
                                                 <tr>
                                                    <th style="border-right: none; border-bottom: 1px solid #CDCDCD; text-align: left; padding: 3px 1px 4px 0; height:50px;">Main client: <asp:CheckBox ID="cb_main_client" runat="server" Text=" " /> </th>
                                                </tr>                                                 
                                                <tr>
                                                    <th style="text-align:left;">Position:</th>
                                                </tr>
                                                 <tr>
                                                    <td style="border-right: none; text-align: left; padding: 3px 1px 4px 0;">
                                                        <asp:TextBox ID="tb_position" runat="server" ValidationGroup="add" CssClass="glowTextbox"/>
                                                        <asp:RequiredFieldValidator ID="PositionValidator" runat="server" ControlToValidate="tb_position" SetFocusOnError="true" Display="Dynamic" ValidationGroup="add">
                                                        <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/Warning.png" ToolTip="Position cannot be blank!" ImageAlign="AbsMiddle"></asp:Image></asp:RequiredFieldValidator>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <th style="text-align:left;">Client name:</th>
                                                </tr>
                                                 <tr>
                                                    <td style="border-right: none; text-align: left; padding: 3px 1px 4px 0;">
                                                        <asp:TextBox ID="tb_client_name" runat="server" ValidationGroup="add" CssClass="glowTextbox"/>
                                                        <asp:RequiredFieldValidator ID="comp_name_Validator" runat="server" ControlToValidate="tb_client_name" SetFocusOnError="true" Display="Dynamic" ValidationGroup="add">
                                                        <asp:Image ID="Image2" runat="server" ImageUrl="~/Images/Warning.png" ToolTip="Company name cannot be blank!" ImageAlign="AbsMiddle"></asp:Image></asp:RequiredFieldValidator>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <th style="text-align:left;">Client registration number:</th>
                                                </tr>
                                                 <tr>
                                                    <td style="border-right: none; text-align: left; padding: 3px 1px 4px 0;">
                                                        <asp:TextBox ID="tb_client_reg_nr" runat="server" ValidationGroup="add" onkeypress="CheckNumeric(event);" MaxLength="11" CssClass="glowTextbox"></asp:TextBox>
                                                        <asp:RequiredFieldValidator ID="client_reg_nr_Validator" runat="server" ControlToValidate="tb_client_reg_nr" SetFocusOnError="true" Display="Dynamic" ValidationGroup="add">
                                                        <asp:Image ID="Image3" runat="server" ImageUrl="~/Images/Warning.png" ToolTip="Registration number cannot be blank!" ImageAlign="AbsMiddle"></asp:Image></asp:RequiredFieldValidator>
                                                        <asp:RegularExpressionValidator ID="rev_client_reg_nr" runat="server" ValidationExpression="^[0-9]{11}$" ControlToValidate="tb_client_reg_nr" ValidationGroup="add">
                                                        <asp:Image ID="Image8" runat="server" ImageUrl="~/Images/Warning.png" ToolTip="Registration number need to be only numbers count 11!" ImageAlign="AbsMiddle"></asp:Image></asp:RegularExpressionValidator>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <th style="border-right: none; border-bottom: 1px solid #CDCDCD; text-align: left; padding: 3px 1px 4px 0; height:50px;">Client vat: <asp:Label ID="lbl_client_vat" runat="server" /> </th>
                                                </tr>                                                                                                
                                            </tbody>
                                         </table>
                                         <div style="text-align:center; padding:10px;">
                                            <asp:Label ID="modal_message_client" runat="server" Text="&nbsp" style="font-size:0.9em; font-weight:bold;"/>
                                         </div>
                                         <div class="buttons">
                                            <asp:button CssClass="BlueBtn" id="bt_add_client" runat="server" causesvalidation="true" OnClick="bt_add_client_Click" validationgroup="add" Text="Save"></asp:button>
                                            <asp:button CssClass="CancelBtn" id="bt_Cancel1" runat="server" OnClick="bt_cancel_Click" causesvalidation="false" Text="Cancel"></asp:button>                                            
                                         </div>                                         
                                    </ContentTemplate>
                                </ajaxToolkit:TabPanel>
                                <ajaxToolkit:TabPanel ID="tab_client_banks" HeaderText="Client banks" runat="server">
                                    <ContentTemplate>
                                        <div class="lists">
                                        <asp:UpdateProgress ID="UpdateProgress2" runat="server" AssociatedUpdatePanelID="Update_bank_list">
                                           <ProgressTemplate>
                                            <div id="progressBackgroundFilter"></div>
                                                <div id="processMessage">
                                                    <asp:Image ID="Please_wait" runat="server" ImageUrl="~/Images/Please_Wait.gif" />
                                                </div>
                                           </ProgressTemplate>
                                        </asp:UpdateProgress>
                                        <asp:UpdatePanel ID="Update_bank_list" runat="server">
                                          <ContentTemplate>
                                            <asp:ListView ID="Bank_list" runat="server" onitemcommand="Bank_list_ItemCommand" onitemediting="Bank_list_ItemEditing" OnItemDeleting="Bank_list_ItemDelete" OnPagePropertiesChanging="Bank_list_PagePropertiesChanging">
                                                 <LayoutTemplate>
                                                    <table ID="gradient-style" style="width:100%;">
                                                          <thead>
                                                              <tr>
                                                                <th>Bank</th>
                                                                <th>Swift</th>
                                                                <th>Account</th>
                                                                <th colspan="5"> Options</th>
                                                              </tr>
                                                           </thead>                          
                                                          <tr ID="itemPlaceholder" runat="server"></tr>                       
                                                            <tfoot>
                                                                <tr>
                                                                    <th style="text-align: right" colspan="5">
                                                                        <asp:DataPager ID="Bank_list_Page" runat="server" PagedControlID="Bank_list" PageSize="5">
                                                                            <Fields>
                                                                                <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" />
                                                                                <asp:NumericPagerField />
                                                                                <asp:TemplatePagerField>
                                                                                    <PagerTemplate>
                                                                                        Page
                                                                                        <asp:Label runat="server" ID="labelCurrentPage" Text="  <%  #  Container.TotalRowCount > 0 ? (Container.StartRowIndex / Container.PageSize) + 1 : 0  %>  " />
                                                                                        /
                                                                                        <asp:Label runat="server" ID="labelTotalPages" Text="  <%  #   Math.Ceiling ((double)Container.TotalRowCount / Container.PageSize)  %>  " />
                                                                                    </PagerTemplate>
                                                                                </asp:TemplatePagerField>
                                                                                <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" />
                                                                            </Fields>
                                                                        </asp:DataPager>
                                                                    </th>
                                                                </tr>
                                                            </tfoot>
                                                    </table>
                                                </LayoutTemplate>
                                                <ItemTemplate>
                                                        <tr>
                                                        <td id="client_bankID" runat="server" visible="false">
                                                            <asp:Label ID="id_client_bankLabel" runat="server" Text='<%# Eval("_id_company_bank") %>' Visible="false"/>
                                                        </td>
                                                        <td id="bankID" runat="server" visible="false">
                                                            <asp:Label ID="id_bankLabel" runat="server" Text='<%# Eval("_id_bank") %>' Visible="false"/>
                                                        </td>
                                                        <td id="clientID" runat="server" visible="false">
                                                            <asp:Label ID="id_companyLabel" runat="server" Text='<%# Eval("_id_company") %>' Visible="false"/>
                                                        </td>
                                                        <td id="accountID" runat="server" visible="false">
                                                            <asp:Label ID="id_accountLabel" runat="server" Text='<%# Eval("_id_account_number") %>' Visible="false"/>
                                                        </td>
                                                        <td>
                                                            <asp:Label ID="bank_nameLabel" runat="server" Text='<%# Eval("_bank_name") %>' />
                                                        </td>
                                                        <td>
                                                            <asp:Label ID="bank_swiftLabel" runat="server" Text='<%# Eval("_bank_swift") %>' />
                                                        </td>
                                                        <td>
                                                            <asp:Label ID="bank_accountLabel" runat="server" Text='<%# Eval("_account") %>' />
                                                        </td>
                                                        <td>
                                                            <asp:ImageButton ID="lnkEdit" runat="server" CommandName="Edit" ImageUrl="~/Images/file_edit.png" ToolTip="Edit" />
                                                        </td>
                                                        <td>
                                                            <asp:ImageButton ID="lnkDelete" runat="server" CommandName="Delete" ImageUrl="~/Images/file_delete.png" ToolTip="Delete" OnClientClick="setToRed()"/>
                                                        </td>
                                                    </tr>
                                                </ItemTemplate>
                                            </asp:ListView>                                            
                                            <div id="content" style="background: none; min-height: 0px;" runat="server">
                                                <div class="box" style="min-height: 0px;">
                                                    <div class="message-notice" id="message_no_bank" runat="server">
                                                        <div class="image">
                                                            <img height="32" alt="Notice" src="Images/notice.png">
                                                        </div>
                                                        <div class="text">
                                                            <h4>Client have no banks!</h4>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <fieldset id="fieldset" style="height:230px;">
                                                 <legend>Add new client bank & account:</legend>                                                    
                                                        <table style="color: #292929; font-family: Arial,Helvetica,sans-serif; font-size: 0.9em; line-height: 1.4em; padding: 5px 7px; width:100%; text-align:left;">
                                                            <tbody>
                                                                 <tr>
                                                                    <th style="text-align:left;">Bank:</th>
                                                                 </tr>
                                                                 <tr>
                                                                    <td style="border-right: none; text-align: left; padding: 3px 1px 4px 0;">
                                                                        <asp:DropDownList ID="Drop_bank" runat="server" CssClass="glowTextbox" Height="28px" />
                                                                        <asp:RequiredFieldValidator ID="rfv_drop_bank" runat="server" ControlToValidate="Drop_bank" SetFocusOnError="true" Display="Dynamic" ValidationGroup="add_bank" InitialValue="--Select--">
                                                                        <asp:Image ID="Image4" runat="server" ImageUrl="~/Images/Warning.png" ToolTip="Select bank!" ImageAlign="AbsMiddle"></asp:Image></asp:RequiredFieldValidator>
                                                                    </td>
                                                                 </tr>
                                                                 <tr>
                                                                    <th style="text-align:left;">Account nr.:</th>
                                                                 </tr>
                                                                 <tr>
                                                                    <td style="border-right: none; text-align: left; padding: 3px 1px 4px 0;">
                                                                        <asp:TextBox ID="tb_account" runat="server" CssClass="glowTextbox" MaxLength="21"/>
                                                                        <asp:RequiredFieldValidator ID="rfv_tb_account" runat="server" ControlToValidate="tb_account" SetFocusOnError="true" Display="Dynamic" ValidationGroup="add_bank">
                                                                        <asp:Image ID="Image5" runat="server" ImageUrl="~/Images/Warning.png" ToolTip="Account number cannot be blank!" ImageAlign="AbsMiddle"></asp:Image></asp:RequiredFieldValidator>
                                                                        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="rev_tb_account" ValidationExpression="^[a-zA-Z0-9]{21}$" ControlToValidate="tb_account" ValidationGroup="add_bank">
                                                                        <asp:Image ID="Image7" runat="server" ImageUrl="~/Images/Warning.png" ToolTip="Account number need to be only numbers and letters and count 21!" ImageAlign="AbsMiddle"></asp:Image></asp:RegularExpressionValidator>
                                                                    </td>
                                                                </tr>
                                                            </tbody>
                                                         </table>
                                                         <div style="text-align:center; padding:10px;">
                                                            <asp:Label ID="modal_message_bank" runat="server" Text="&nbsp" style="font-size:0.9em; font-weight:bold;"/>
                                                         </div>
                                                    <div class="buttons">
                                                        <asp:Button ID="bt_ok_bank" runat="server" OnClick="bt_ok_bank_Click" Text="Add" ValidationGroup="add_bank" CssClass="GreenBtn" /> 
                                                        <asp:Button  ID="bt_cancel_bank" runat="server" OnClick="bt_cancel_bank_Click" causesvalidation="false" Text="Cancel" CssClass="CancelBtn"></asp:button>                                                           
                                                    </div>
                                                <asp:Label ID="lbl_edit_bank" runat="server" Text="" />
                                                <asp:Label ID="lbl_client_bank_id" runat="server" Text=""/>
                                                <asp:Label ID="lbl_bank_id" runat="server" Text=""/>
                                                <asp:Label ID="lbl_account_id" runat="server" Text=""/>
                                           </fieldset>                                           
                                         </ContentTemplate>
                                       </asp:UpdatePanel>
                                       </div>
                                    </ContentTemplate>
                                </ajaxToolkit:TabPanel>
                                <ajaxToolkit:TabPanel ID="tab_client_address" HeaderText="Client address" runat="server">
                                    <ContentTemplate>
                                        <div class="lists">
                                            <asp:UpdateProgress ID="UpdateProgress3" runat="server" AssociatedUpdatePanelID="Update_client_address_list">
                                               <ProgressTemplate>
                                                <div id="progressBackgroundFilter"></div>
                                                    <div id="processMessage">
                                                        <asp:Image ID="Please_wait" runat="server" ImageUrl="~/Images/Please_Wait.gif" />
                                                    </div>
                                               </ProgressTemplate>
                                            </asp:UpdateProgress>
                                            <asp:UpdatePanel ID="Update_client_address_list" runat="server">
                                            <ContentTemplate>                                            
                                                <asp:ListView ID="Address_list" runat="server" onitemcommand="Address_list_ItemCommand" onitemediting="Address_list_ItemEditing" OnItemDeleting="Address_list_ItemDeleting" OnPagePropertiesChanging="Address_list_PagePropertiesChanging">
                                                     <LayoutTemplate>
                                                        <table id="gradient-style" style="width:100%;">
                                                            <thead>
                                                                <tr>
                                                                    <th>Address</th>
                                                                    <th colspan="2"> Options</th>
                                                                </tr>
                                                            </thead>
                                                            <tr ID="itemPlaceholder" runat="server"></tr>                       
                                                            <tfoot>
                                                                <tr>
                                                                    <th style="text-align: right" colspan="3">
                                                                        <asp:DataPager ID="Address_list_Page" runat="server" PagedControlID="Address_list" PageSize="5">
                                                                            <Fields>
                                                                                <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" />
                                                                                <asp:NumericPagerField />
                                                                                <asp:TemplatePagerField>
                                                                                    <PagerTemplate>
                                                                                        Page
                                                                                        <asp:Label runat="server" ID="labelCurrentPage" Text="  <%  #  Container.TotalRowCount > 0 ? (Container.StartRowIndex / Container.PageSize) + 1 : 0  %>  " />
                                                                                        /
                                                                                        <asp:Label runat="server" ID="labelTotalPages" Text="  <%  #   Math.Ceiling ((double)Container.TotalRowCount / Container.PageSize)  %>  " />
                                                                                    </PagerTemplate>
                                                                                </asp:TemplatePagerField>
                                                                                <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" />
                                                                            </Fields>
                                                                        </asp:DataPager>
                                                                    </th>
                                                                </tr>
                                                            </tfoot>
                                                        </table>
                                                    </LayoutTemplate>
                                                    <ItemTemplate>
                                                        <tr>
                                                            <td id="addressID" runat="server" visible="false">
                                                                <asp:Label ID="id_addressLabel" runat="server" Text='<%# Eval("_id_address") %>' Visible="false"/>
                                                            </td>
                                                            <td id="clientID" runat="server" visible="false">
                                                                <asp:Label ID="id_clientLabel" runat="server" Text='<%# Eval("_id_company") %>' Visible="false" />
                                                            </td>
                                                            <td>
                                                                <asp:Label ID="addressLabel" runat="server" Text='<%# Eval("_address") %>' />
                                                            </td>
                                                            <td>
                                                                <asp:ImageButton ID="lnkEdit" runat="server" CommandName="Edit" ImageUrl="~/Images/file_edit.png" ToolTip="Edit" />
                                                            </td>
                                                            <td>
                                                                <asp:ImageButton ID="lnkDelete" runat="server" CommandName="Delete" ImageUrl="~/Images/file_delete.png" ToolTip="Delete"/>
                                                            </td>
                                                        </tr>
                                                    </ItemTemplate>
                                                    </asp:ListView>
                                                    <div id="content1" style="background: none; min-height: 0px;" runat="server">
                                                        <div class="box" style="min-height: 0px;">
                                                            <div class="message-notice" id="message_no_addresses" runat="server">
                                                                <div class="image">
                                                                    <img height="32" alt="Notice" src="Images/notice.png">
                                                                </div>
                                                                <div class="text">
                                                                    <h4>Client have no addresses!</h4>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                <fieldset id="fieldset" style="height:230px;">
                                                        <legend>Add new client address</legend>
                                                            <table  style="color: #292929; font-family: Arial,Helvetica,sans-serif; font-size: 0.9em; line-height: 1.4em; padding: 5px 7px; width:100%; text-align:left;">
                                                                <tbody>
                                                                    <tr>
                                                                        <th style="text-align:left;">Address:</th>
                                                                    </tr>
                                                                    <tr>
                                                                        <td style="border-right: none; text-align: left; padding: 3px 1px 4px 0;">
                                                                            <asp:TextBox ID="tb_address" TextMode="MultiLine" runat="server" CssClass="glowTextbox" Width="500px" Height="80px"/>
                                                                            <asp:RequiredFieldValidator ID="rfv_tb_address" runat="server" ControlToValidate="tb_address" SetFocusOnError="true" Display="Dynamic" ValidationGroup="add_address">
                                                                            <asp:Image ID="Image6" runat="server" ImageUrl="~/Images/Warning.png" ToolTip="Address cannot be blank!" ImageAlign="AbsMiddle"></asp:Image></asp:RequiredFieldValidator>
                                                                        </td>
                                                                    </tr>
                                                                </tbody>
                                                             </table>
                                                             <div style="text-align:center; padding:10px;">
                                                                <asp:Label ID="modal_message_address" runat="server" Text="&nbsp" style="font-size:0.9em; font-weight:bold;"/>
                                                             </div>
                                                             <div class="buttons">
                                                                <asp:Button ID="bt_ok_address" runat="server" OnClick="bt_ok_address_Click" Text="Add" ValidationGroup="add_address" CssClass="GreenBtn" />
                                                                <asp:Button  ID="bt_cancel_address" runat="server" OnClick="bt_cancel_address_Click" causesvalidation="false" Text="Cancel" CssClass="CancelBtn"></asp:button>                                                            
                                                            </div>
                                                            <asp:Label ID="lbl_edit_address" runat="server" Text="Edit" />
                                                            <asp:Label ID="lbl_address_id" runat="server" Text=""/>                                                    
                                                    </fieldset>
                                            </ContentTemplate>
                                         </asp:UpdatePanel>
                                        </div>
                                    </ContentTemplate>
                                </ajaxToolkit:TabPanel>
                            </ajaxToolkit:TabContainer>
                            </ContentTemplate>
                          </asp:Updatepanel>
                        <div class="buttons" style="visibility:hidden;">
                            <asp:button CssClass="CancelBtn" id="bt_Cancel" runat="server" causesvalidation="false" Text="Cancel"></asp:button>
                        </div>
                        </div> 
                     </div>
                    <asp:hiddenfield id="HiddenField" runat="server" />
                    <ajaxToolkit:ModalPopupExtender ID="Modal_add_client" runat="server" TargetControlID="HiddenField" PopupControlID="Add_client" CancelControlID="bt_Cancel" BackgroundCssClass="modalPopupBackground" />
                </asp:Panel>

                <%--Delete Client Popup --%>
                <asp:Panel ID="PopupDelete" runat="server" CssClass="popupBody" style="display: none">
                    <div class="popupContainer" style="width: auto; min-width: 400px">
                        <div class="popupTitlebar">
                            <div class="titlebarLeft">
                                <asp:Literal ID="Literal1" runat="server" Text="Delete!" />
                            </div>
                            <div class="titlebarRight" onclick="OnCancelDelete();"></div>
                        </div>
                        <div class="popupBody">
                            <div id="content" style="background: none; min-height: 0px;">
                                <asp:Label ID="lbl_ClientID" runat="server" />
                                <asp:Label ID="lbl_selected_clients" runat="server" />
                                <div class="box" style="min-height: 0px;">
                                    <div class="message-notice" id="message4" runat="server">
                                        <div class="image">
                                            <img height="32" alt="Notice" src="Images/notice.png">
                                        </div>
                                        <div class="text">
                                            <h4>Are you sure?</h4>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="buttons">
                            <button class="BlueBtn" id="bt_delete_client" runat="server" onserverclick="bt_delete_client_Click" style="width: auto;"><span class="label">Delete</span></button>
                            <button class="CancelBtn" id="bt_Cancel_delete" runat="server" onserverclick="bt_delete_cancel_Click" style="width: auto;"><span class="label">Cancel</span></button>
                        </div>
                    </div>
                </asp:Panel>
                <asp:hiddenfield id="HiddenField7" runat="server" />
                <ajaxToolkit:ModalPopupExtender ID="Modal_Popup_Delete" runat="server" TargetControlID="HiddenField7" PopupControlID="PopupDelete" CancelControlID="bt_Cancel_delete" BackgroundCssClass="modalPopupBackground" />                
                </ContentTemplate>
                </asp:UpdatePanel>
                <div style="padding-top: 15px;">
                    <asp:Button ID="Button2" runat="server" OnClick="bt_add_new_client_Click" Text="Add new client" CssClass="GreenBtn" />
                    <asp:Button ID="bt_delete" runat="server" OnClick="bt_delete_clients_Click" Text="Delete selected clients" CssClass="BlueBtn" />
                </div>
               </div>
              </div>                
            </asp:Panel>            
          </div>
        <script type="text/javascript">
            function OnCancel() {
                document.getElementById('<%=bt_Cancel.ClientID%>').click();
            }

            function CheckNumeric(e) {
                if (window.event) // IE 
                {
                    if ((e.keyCode < 48 || e.keyCode > 57) & e.keyCode != 8) {
                        event.returnValue = false;
                        return false;
                    }
                }
                else { // Fire Fox
                    if ((e.which < 48 || e.which > 57) & e.which != 8) {
                        e.preventDefault();
                        return false;
                    }
                }
            }
        </script>
</asp:Content>

